<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
	    <link rel="stylesheet" href="${pageContext.request.contextPath}/css/amazeui.min.css">
		<link rel="stylesheet" href="${pageContext.request.contextPath}/css/admin.css">
		<link rel="stylesheet" href="css/app.css">
		<style>
			.admin-main{
				padding-top: 0px;
			}
		</style>
		<script>
			function checkPwd(){
				var password=document.frm.password.value;
				var pwd_confirm=document.frm.pwd.value;
				var oldPassword=document.frm.oldPassword.value;
				var datas={};
				if(password!=pwd_confirm){
					alert("两次密码不一致！");
					return false;
				}
				datas.password=password;
				datas.oldPassword=oldPassword;
				$.ajax({
					async:false,
					type: "POST",
					url: "/admin/doupdatePwd",//注意路径
					data:datas,
					dataType:"json",
					success:function(data){
						if(data.result=='SUCCESS'){
							alert("修改成功");
							parent.location.reload();
						}else{
							alert("修改失败，失败原因【" + data.result + "】");
						}
					},
					error:function(data){
						alert(data.result);
					}
				});

				return true;
			}
		</script>
	</head>

	<body>
		<div class="am-cf admin-main">
		<!-- content start -->
		<div class="admin-content">
			<div class="admin-content-body">
				<div class="am-g">
					<form class="am-form am-form-horizontal" name="frm"
						 method="post" onsubmit="return checkPwd();"
						style="padding-top:30px;" data-am-validator>
						<div class="am-form-group">
							<label  class="am-u-sm-3 am-form-label">
								旧密码 </label>
							<div class="am-u-sm-9">
								<input type="password" id="doc-vld-pwd-0" required placeholder="请输入旧密码"
									   name="oldPassword">
							</div>
						</div>
						<div class="am-form-group">
							<label  class="am-u-sm-3 am-form-label">
							新密码 </label>
							<div class="am-u-sm-9">
								<input type="password" id="doc-vld-pwd-1" required placeholder="请输入新密码"
									name="password">
							</div>
						</div>
						<div class="am-form-group">
							<label  class="am-u-sm-3 am-form-label">
								重复密码</label>
							<div class="am-u-sm-9">
								<input type="password" id="doc-vld-pwd-2" required placeholder="请输入重复密码" 
									name="pwd"  data-equal-to="#doc-vld-pwd-1"  required>
							</div>
						</div>
						<label class="am-u-sm-3 am-form-label" style="color:red;">${sessionScope.errmsg3}</label>
						<div class="am-form-group">
							<div class="am-u-sm-9 am-u-sm-push-3">
								<input type="submit" class="am-btn am-btn-success" value="修改密码" />
							</div>
						</div>
					</form>
				</div>
			</div>
		</div>
	</div>
	<script type="text/javascript"
		src="${pageContext.request.contextPath}/js/jquery-1.11.3.min.js">
	</script>
	<script type="text/javascript" src="${pageContext.request.contextPath}/myplugs/js/plugs.js">
	</script>
	</body>
</html>
